﻿using Furion.DatabaseAccessor;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GSOrganization.EntityFramework.Core.Attrubute
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class CustomDbContextAttribute : AppDbContextAttribute
    {
        public CustomDbContextAttribute()
        {
            // 读取配置文件  
            var configuration = new ConfigurationBuilder()
                .SetBasePath(AppContext.BaseDirectory)
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .Build();
            var connectionString = configuration["ConnectionStrings:ConnectionString"];
            var dbType = configuration["ConnectionStrings:DbContextType"];
            ConnectionMetadata = connectionString;
            ProviderName = dbType;
        }
    }
}
